package com.innjia.base.utils.pdf;

import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPageEventHelper;
import com.itextpdf.text.pdf.PdfWriter;

/**
 * 页脚工具类
 * @author mbc
 *
 */
public class Footer extends PdfPageEventHelper {
    private Phrase p;

    public Footer(){}

    public Footer(Phrase p){
        this.p = p;
    }

    public void onEndPage(PdfWriter writer, Document document) {
        PdfContentByte cb = writer.getDirectContent();
        ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, this.p,
                (document.right() - document.left()) / 2 + document.leftMargin(), document.bottom() - 10, 0);
    }


}
